from math import sqrt,acos

# 多维相加
def add(*vectors):
    by_coordinate = zip(*vectors) # zip()是将x集合、y集合、z集合依次提前为(x,y,z)
    coordinate_sums = [sum(coords) for coords in by_coordinate]
    return  tuple(coordinate_sums)

# 多维长度计算
def length(v):
    return sqrt(sum([coord ** 2 for coord in v]))

# 多维向量乘以标量
def scale(scalar,v):
    return tuple(scalar * coord for coord in v)

# 点积计算
def dot(u,v):
    return sum([coord1 * coord2 for coord1 , coord2 in zip(u,v)])

# 计算两向量夹角的角度
def angle_between(v1,v2):
    return acos(
        dot(v1,v2) / (length(v1) * length(v2))
    )